<!---
流程意见, 列表或者时间轴
--->
<template>
  <avic-bpm-tracking-template :ref="refName" :flow-param="tracksParam" :current-tab="currentTab" />
</template>
<script>
import AvicBpmTrackingTemplate from '../../bpm-tracking-template/index.vue';
import bpmUtils from '../../../../bpmutils/FlowUtils';

export default {
  name: 'AvicBpmTracking',
  components: {
    AvicBpmTrackingTemplate
  },
  props: {
    bpmInstanceObject: {
      type: Object,
      default: null
    },
    currentTab: {
      type: String,
      default: 'tracking'
    }
  },
  data() {
    return {
      trackUrl: `${bpmUtils.baseurl}/business/doGettracksByPage/v2`,
      timeLineurl: `${bpmUtils.baseurl}/business/doGetTimeTracks/v1`,
      tracksParam: {
        url: '',
        parameter: {
          entryId: ''
        },
        method: 'post'
      },
      entryId: '',
      refName: 'flowTracking'
    };
  },
  watch: {
    'bpmInstanceObject.bpmModel.entryId': {
      immediate: true,
      handler(entryId) {
        if (this.entryId !== entryId) {
          this.entryId = entryId;
          this.loadData();
        }
      }
    }
  },
  mounted() {
    this.entryId = this.bpmInstanceObject.bpmModel.entryId;
    this.loadData();
  },
  methods: {
    loadData() {
      if (this.entryId) {
        this.tracksParam.parameter.entryId = this.entryId;
        this.tracksParam.trackUrl = this.trackUrl;
        this.tracksParam.timeLineUrl = this.timeLineurl;
        if (this.$refs[this.refName]) {
          this.$refs[this.refName].refreshFlowTracking();
        }
      }
    }
  }
};
</script>
<style lang="less" scoped></style>
